/**
 * @fileOverview
 * WashizuMahjong.
 * http://code.google.com/p/washizu-mahjong/
 */
/**
 * @class
 * @param {String}	actionType
 * @param {Player}	[player]
 * @param {MahjongTile}	[tile]
 * @param {Player}	[actedplayer]
 * @param {Object}	[otherInfo]
 */
function ActionMessage(actionType, player, tile, actedplayer, otherInfo){
	if(!(this instanceof ActionMessage))
		return new ActionMessage(actionType, player, tile, actedplayer, otherInfo);
	if(!actionType){
		return;
	}
	this.type = actionType;
	if(player && (player instanceof Player)){
		this.player = player;
	}
	if(tile && (tile instanceof MahjongTile)){
		this.tile = tile;
	}
	this.actedPlayer = actedplayer || null;
	this.otherInfo = otherInfo || null;
	if(this.callback && typeof(this.callback) == "function")
		this.callback();
}
/**
 * ActionMessage type.
 * @see	ActionMessage.AddDora
 * @see	ActionMessage.AddTile
 * @see	ActionMessage.Chow
 * @see	ActionMessage.Discard
 * @see	ActionMessage.Kong
 * @see	ActionMessage.NewRound
 * @see	ActionMessage.PayScore
 * @see	ActionMessage.PickUp
 * @see	ActionMessage.Pong
 * @see	ActionMessage.ReciveScore
 * @see	ActionMessage.Richi
 * @see	ActionMessage.AbortiveDraw
 * @see	ActionMessage.DrawRound
 * @see	ActionMessage.SelfDrawn
 * @see	ActionMessage.Ron
 * @type String
 */
ActionMessage.prototype.type = null;
/**
 * The player did the action.
 * @type Player
 */
ActionMessage.prototype.player = null;
/**
 * The player be acted. For example, the player discard the tile when the pong action happen.
 * @type Player
 * @default null
 */
ActionMessage.prototype.actedPlayer = null;
/**
 * @type MahjongTile
 */
ActionMessage.prototype.tile = null;
/**
 * Other informations about the action.
 * @type Object
 */
ActionMessage.prototype.otherInfo = {};
/**
 * The callback function, it can be used for storing game data.
 * @type function
 */
ActionMessage.prototype.callback = function(){
	console.log(this.player|| "", this.type, this.tile, this.actedPlayer || "", this.otherInfo || "",new Date());
};
/**
 * @type String
 */
ActionMessage.PickUp = "Pick Up";
/**
 * @type String
 */
ActionMessage.AddTile = "Add Tile into Hand";
/**
 * @type String
 */
ActionMessage.Kong = "Kong";
/**
 * @type String
 */
ActionMessage.Chow = "Chow";
/**
 * @type String
 */
ActionMessage.Pong = "Pong";
/**
 * @type String
 */
ActionMessage.Discard = "Discard";
/**
 * @type String
 */
ActionMessage.AddDora = "AddDora";
/**
 * @type String
 */
ActionMessage.Richi = "Richi";
/**
 * @type String
 */
ActionMessage.ReciveScore = "Recive Score";
/**
 * @type String
 */
ActionMessage.PayScore = "Pay Score";
/**
 * @type String
 */
ActionMessage.NewRound = "New Round";
/**
 * @type String
 */
ActionMessage.AbortiveDraw = "Abortive Draw";
/**
 * @type String
 */
ActionMessage.DrawRound = "Draw Round";
/**
 * @type String
 */
ActionMessage.Ron = "Picking Up a Discard";
/**
 * @type String
 */
ActionMessage.SelfDrawn = "Self-Drawn";